<template>
  <view v-if="visible" class="weather-alert-modal-mask" @click="handleClose">
    <view class="weather-alert-modal" @click.stop>
      <view class="weather-alert-header">
        <weather-icon :weather-code="weatherCode" size="24" color="#333" />
        <text class="weather-alert-title">{{ title }}</text>
      </view>
      <view class="weather-alert-content">
        <text class="weather-alert-text">{{ content }}</text>
      </view>
      <view class="weather-alert-footer">
        <view class="weather-alert-button" @click="handleConfirm">知道了</view>
      </view>
    </view>
  </view>
</template>

<script>
import WeatherIcon from './WeatherIcon.vue';

export default {
  name: 'WeatherAlertModal',
  components: {
    WeatherIcon
  },
  props: {
    // 是否显示弹窗
    visible: {
      type: Boolean,
      default: false
    },
    // 弹窗标题
    title: {
      type: String,
      default: '天气提示'
    },
    // 弹窗内容
    content: {
      type: String,
      default: ''
    },
    // 天气编码
    weatherCode: {
      type: String,
      default: 'd00'
    },
    // 确认按钮颜色
    confirmColor: {
      type: String,
      default: '#007aff'
    }
  },
  methods: {
    // 关闭弹窗
    handleClose() {
      this.$emit('close');
    },
    // 确认按钮点击
    handleConfirm() {
      this.$emit('confirm');
    }
  }
};
</script>

<style scoped>
.weather-alert-modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.weather-alert-modal {
  width: 80%;
  max-width: 600rpx;
  background-color: #fff;
  border-radius: 20rpx;
  overflow: hidden;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
}

.weather-alert-header {
  display: flex;
  align-items: center;
  padding: 30rpx 40rpx;
  border-bottom: 1rpx solid #eee;
}

.weather-alert-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
  margin-left: 20rpx;
}

.weather-alert-content {
  padding: 40rpx;
}

.weather-alert-text {
  font-size: 32rpx;
  color: #333;
  line-height: 1.5;
}

.weather-alert-footer {
  padding: 20rpx 40rpx 30rpx;
  display: flex;
  justify-content: center;
}

.weather-alert-button {
  padding: 20rpx 60rpx;
  background-color: v-bind(confirmColor);
  color: #fff;
  font-size: 32rpx;
  border-radius: 100rpx;
  text-align: center;
}
</style>